package com.appkubes.mall.restful.application.store.service.impl;

import com.appkubes.mall.core.entity.MallStore;
import com.appkubes.mall.core.service.impl.BaseMallStoreServiceImpl;
import com.appkubes.mall.restful.application.store.dao.StoreDao;
import com.appkubes.mall.restful.application.store.entity.vo.ApplyStoreVO;
import com.appkubes.mall.restful.application.store.entity.vo.StoreInfoVO;
import com.appkubes.mall.restful.application.store.service.StoreService;
import com.appkubes.mall.restful.application.user.user.dao.UserStoreDao;
import com.appkubes.mall.restful.application.user.user.service.UserStoreService;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
@Data
public class StoreServiceImpl extends BaseMallStoreServiceImpl implements StoreService {
    @Resource
    StoreDao storeDao;

    @Resource
    UserStoreDao userStoreDao;

    @Resource
    UserStoreService userStoreService;

    public Boolean add(ApplyStoreVO applyStoreVO) {
        //添加到门店表
        MallStore mallStore = new MallStore();
        BeanUtils.copyProperties(applyStoreVO, mallStore);
        mallStore.setStatus("PENDING");
        mallStore.setCreateTime(new Date());
        mallStore.setAppKey(null);
        return this.save(mallStore);
    }

    public List<MallStore> getUserStore(StoreInfoVO storeInfoVO) {
        MallStore query = new MallStore();
        BeanUtils.copyProperties(storeInfoVO, query);
        List<MallStore> mallStoreList = this.selectListByEntity(query);
        return mallStoreList;
    }

}
